package org.jsola.hr.helper;

import org.jsola.hr.constant.EmpInfoRequireType;
import org.jsola.hr.constant.EmpInfoScene;
import org.jsola.hr.dto.EmpContactsRequireAddDTO;
import org.jsola.hr.dto.EmpContactsRequireUpdateDTO;
import org.jsola.hr.entity.EmpContactsRequireDO;
import org.jsola.hr.query.EmpContactsRequireQuery;
import org.jsola.hr.service.IEmpContactsRequireService;
import org.jsola.hr.vo.EmpContactsRequireVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * @author zhr
 */
@Component
public class EmpContactsRequireTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpContactsRequireService empContactsRequireService;

    /**
     * 生成add测试数据
     * @return EmpContactsRequireAddDTO
     */
    public EmpContactsRequireAddDTO getEmpContactsRequireAddDTO(){
        EmpContactsRequireAddDTO empContactsRequireAddDTO = new EmpContactsRequireAddDTO();
        empContactsRequireAddDTO.setCompanyId(getRandomValue("varchar",32));
        empContactsRequireAddDTO.setRequireType(EmpInfoScene.DAILY.getValue());
        empContactsRequireAddDTO.setName(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setRelation(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setBirthday(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setPhone(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setCompany(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setPosition(EmpInfoRequireType.NO_NEED.getValue());
        empContactsRequireAddDTO.setPoliticalStatus(EmpInfoRequireType.NO_NEED.getValue());
        return empContactsRequireAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpContactsRequireUpdateDTO
     */
    public EmpContactsRequireUpdateDTO getEmpContactsRequireUpdateDTO(EmpContactsRequireVO empContactsRequireVO){
        return empContactsRequireService.selectDOById(empContactsRequireVO.getId(), SITE_ID).to(EmpContactsRequireUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpContactsRequireQuery
     */
    public EmpContactsRequireQuery getEmpContactsRequireQuery() {
        EmpContactsRequireQuery empContactsRequireQuery = new EmpContactsRequireQuery();
        List<EmpContactsRequireDO> empContactsRequireDOList = empContactsRequireService.list(new EmpContactsRequireDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empContactsRequireDOList)) {
            EmpContactsRequireDO empContactsRequireDO = empContactsRequireDOList.get(0);
            empContactsRequireQuery = empContactsRequireDO.to(EmpContactsRequireQuery.class);
        }
        return empContactsRequireQuery;
    }

    /**
     * 保存示例
     * @return EmpContactsRequireVO
     */
    public EmpContactsRequireVO saveEmpContactsRequireExample(){
        EmpContactsRequireAddDTO addDTO = this.getEmpContactsRequireAddDTO();
        EmpContactsRequireVO empContactsRequireVO = empContactsRequireService.save(addDTO,buildTokenUser());
        return empContactsRequireVO;
    }


}

